<template>
    <div>
        <el-table border
                  :data="tableData" stripe
                  style="width: 100%;height: 100%"
                  @selection-change="handleSelectionChange">
            <el-table-column
                    label="序号"
                    type="index"
                    width="50"
                    align="center">
                <template slot-scope="{row, $index}">
                    <span>{{(curPage - 1) * 10 + $index + 1}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="taskName" label="任务名称" :min-width="150">
                <template slot-scope="{row, $index}">
                    <span v-if="row.releaseTask">{{row.releaseTask.taskName}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="taskName" label="所属系统" :min-width="150">
                <template slot-scope="{row, $index}">
                    <span v-if="row.releaseTask">{{type[row.releaseTask.type-1]}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="taskName" label="日志类别" :min-width="160">
                <template slot-scope="{row, $index}">
                    <span v-if="row.logType">{{logType[row.logType-1]}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="userName" label="操作人" :min-width="150">
                <template slot-scope="{row, $index}">
                    <span v-if="row.user"><span style="font-size: 14px;color: #97a8be;font-weight: 400">管理员:</span>{{row.user.userName}}</span>
                    <span v-else-if="row.users"><span
                            style="font-size: 14px;color: #97a8be;font-weight: 400">调查员:</span>{{row.users.userName}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="updateTime" label="操作时间" :min-width="160">
                <template slot-scope="{row, $index}">
                    <span>{{row.logTime}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="taskState" label="任务状态" :min-width="160">
                <template slot-scope="{row, $index}">
                    <span>{{state[row.taskState - 1]}}</span>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="data" label="操作" :min-width="100">
                <template slot-scope="{row, $index}">
                    <el-button class="el-button el-button--mini el-button--danger"
                               @click="opDialog(row.id)">删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <msg-dialog @yes="deleteLog" @no="onCancel" :dialog-visible="dialogVisible"
                    :msg="msg"></msg-dialog>
    </div>
</template>
<script>
    import MsgDialog from "../../menu/MsgDialog";
    import qs from "qs";

    export default {
        name: "UserLogTable",
        components: {
            MsgDialog
        },
        data() {
            return {
                msg: '',
                editTaskName: false,
                editRemark: false,
                multipleSelection: [],
                state: ["新发布", "已认领", "数据有上传", "等待质检", "质检不合格", "质检合格", "数据入库"],
                dialogVisible: false,
                chooseId: -1,
                type: ["建筑系统","供水系统","燃气系统","交通系统","电力系统","通信系统"],
                logType: ["调查任务认领","调查数据包更新","调查任务质检","调查任务入库"]
            }
        },
        props: {
            tableData: {
                type: Array,
                defult
    :
    []
    }
    ,
    curPage: {
        type: Number,
            defult
    :
        1
    }
    }
    ,
    methods: {
        download(url)
        {
            window.open(url);
        }
    ,
        startQc(id)
        {
            this.chooseId = id;
            this.$emit('startQc', this.chooseId);
        }
    ,
        opDialog(id)
        {
            this.msg = '确认删除此条数据？';
            this.dialogVisible = true;
            this.chooseId = id;
        }
    ,
        to(path)
        {
            this.$router.push({name: path});
        }
    ,
        toggleSelection(rows)
        {
            if (rows) {
                rows.forEach(row => {
                    this.$refs.taskTable.toggleRowSelection(row);
                });
            } else {
                this.$refs.taskTable.clearSelection();
            }
        }
    ,
        handleSelectionChange(val)
        {
            this.multipleSelection = val;
        }
    ,
        filterHandler(value, row, column)
        {
            const property = column['property'];
            return row[property] === value;
        }
    ,
        resetDateFilter()
        {
            this.$refs.taskTable.clearFilter('data');
        }
    ,
        clearFilter()
        {
            this.$refs.taskTable.clearFilter();
        }
    ,
        onCancel()
        {
            this.dialogVisible = false;
            this.chooseId = -1;
        }
    ,
        deleteLog()
        {
            axios.post("/bjdzms/userLog/del",
                qs.stringify({
                    'id': this.chooseId
                })).then(data => {
                this.total = data.data;
                this.dialogVisible = false;
                this.$emit('updateData');
            });
        }
    }
    ,
    }
</script>

<style scoped>

</style>
